package com.metagurukul.informer.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.metagurukul.informer.service.TagSearchService;

/**
 * Servlet implementation class AutoCompleteTags
 */
@WebServlet("/AutoCompleteTags")
public class AutoCompleteTags extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
   
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPerform(request,response);
	}

	private void doPerform(HttpServletRequest request,HttpServletResponse response) {
		try {
			response.setContentType("text/html");
			PrintWriter out=response.getWriter();
			String str=request.getParameter("queryString");
			TagSearchService tagSearch=new TagSearchService();
			String tagList= tagSearch.findByTagName(str);
			out.println(tagList);
		}  catch (Exception e) {
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPerform(request,response);
	}

}
